package ClassesBasicas;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "historico")
public class Historico {
	
	@Id
	@GeneratedValue
	@Column (name="sequencial")
	private int sequencial;
	
	@Column (name="data_historico")
	private Date data;
	
	@Column (name="evolucao")
	private String evolucao;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "codigo_pessoa",
						insertable = true, updatable = true)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)
	private Paciente paciente;
	
	public Paciente getPaciente() {
		return paciente;
	}

	public void setPaciente(Paciente paciente) {
		this.paciente = paciente;
	}

	public Historico(){	
	}
	
	public Historico(Date data, String evolucao) {
		this.data = data;
		this.evolucao = evolucao;
	}
	public Date getData() {
		return data;
	}
	public int getSequencial() {
		return sequencial;
	}
	public void setData(Date data) {
		this.data = data;
	}
	public String getEvolucao() {
		return evolucao;
	}
	public void setEvolucao(String evolucao) {
		this.evolucao = evolucao;
	}	
}
